package com.neusoft.service;

import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.neusoft.bean.AdminInfoBean;
import com.neusoft.db.DBProvider;
import com.neusoft.myutils.MyUtil;

public class AdminInfoService {
	
	/**
	 * 验证登录
	 * 根据表单中输入的用户名和密码作为数据查询条件进行查询
	 * 
	 * @param aib
	 * 			实体bean对象
	 * @return	查询结果集
	 */
	public List<AdminInfoBean> doAdminLogined(AdminInfoBean aib){
		//默认值
		List<AdminInfoBean> adminLst = null;
		//sql查询语句
		String sql = "select * from admininfo where adminname =? and adminpsw=?";
		//调用DBProvider中的查询方法进行查询操作
		adminLst = MyUtil.getInstance(DBProvider.class).query(
				sql, new BeanListHandler<>(AdminInfoBean.class), aib.getAdminName(),aib.getAdminPsw());
		return adminLst;
	}
	
	
	public int doAddAdminInfo(AdminInfoBean aib) {
		int i = 0;
		String sql = "insert into admininfo(adminName,adminPsw,adminSex,adminAge,adminTel,adminEmail) "
				+ "values(?,?,?,?,?,?)";
		i = MyUtil.getInstance(DBProvider.class).update(sql, aib.getAdminName(),
				aib.getAdminPsw(),aib.getAdminSex(),aib.getAdminAge(),aib.getAdminTel(),aib.getAdminEmail());
		return i;
		
	}
	
	
}
